//package com.example.tool.web;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.dingtalk.api.DefaultDingTalkClient;
//import com.dingtalk.api.DingTalkClient;
//import com.dingtalk.api.request.OapiRobotSendRequest;
//import com.dingtalk.api.response.OapiRobotSendResponse;
//import com.taobao.api.ApiException;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//
//public class DingDingToolController {
//    private static final String TEXT = "text消息";
//
//    /**
//     * 实现机器人发送消息
//     */
//    @PostMapping("robots")
//    public String helloRobots(@RequestBody(required = false) JSONObject json) {
//        System.out.println(JSON.toJSONString(json));
//        String content = json.getJSONObject("text").get("content").toString().replaceAll(" ", "");
//        System.out.println(content);
//        String sessionWebhook = json.getString("sessionWebhook");
//        DingTalkClient client = new DefaultDingTalkClient(sessionWebhook);
//        if (TEXT.equals(content)) {
//            text(client);
//        }
//        return null;
//    }
//
//    /**
//     * text文本消息
//     *
//     * @param client
//     */
//    private void text(DingTalkClient client) {
//        try {
//            OapiRobotSendRequest request = new OapiRobotSendRequest();
//            request.setMsgtype("text");
//            OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
//            text.setContent("日报发送失败! 钉钉群名称与项目名称未关联!!!");
//            request.setText(text);
//            OapiRobotSendResponse response = client.execute(request);
//            System.out.println(response.getBody());
//        } catch (ApiException e) {
//            e.printStackTrace();
//        }
//    }
//}
